home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
2410
/
2410.xpi
/
chrome
/
content
/
foxmarks-overlay.js
< prev
next >
Wrap
Text File
|
2010-01-28
|
3KB
|
97 lines
/*
Copyright 2005-2007 Foxmarks Inc.
foxmarks-overlay.js: implement the foxmarks overlay into the main browser
window
*/
var Xmarks;
if(Xmarks === undefined){
Xmarks = {};
}
(function() {
var xm = Xmarks;
var foxmarksObserver = {
observe: function(subject, topic, data) {
var result = eval(data);
//ignore component finish messages
if(result.status == 3)
return;
var status = result.status;
var msg = result.msg || "";
var complete = status != 1;
window.XULBrowserWindow.setJSStatus("Xmarks: " + msg);
if (complete) {
setTimeout(foxmarksObserver.clearStatus, status != 0 ? 5000: 1000);
}
},
clearStatus: function() {
window.XULBrowserWindow.setJSStatus("");
}
}
var foxmarksPopupObserver = {
observe: function(subject, topic, data) {
var JSON = Cc["@mozilla.org/dom/json;1"].
createInstance(Ci.nsIJSON);
xm.NewUserPopup(JSON.decode(data));
}
}
xm.SetKeyboardShortcut = function(id, key) {
var element = document.getElementById(id);
element.setAttribute("key", key);
element.setAttribute("disabled", key ? false : true);
};
function FoxmarksBrowserLoad() {
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.addObserver(foxmarksObserver, "foxmarks-service", false);
os.addObserver(foxmarksPopupObserver, "foxmarks-newpopup", false);
xm.SetKeyboardShortcut("XmarksSyncNow", xm.gSettings.syncShortcutKey);
xm.SetKeyboardShortcut("OpenFoxmarksDialog",
xm.gSettings.openSettingsDialogShortcutKey);
xm.SetKeyboardShortcut("FoxmarksSimSiteKey",
xm.gSettings.siteinfoDialogShortcutKey);
// Load SERP
Xmarks.SERP.init();
// Load similiar sites
Xmarks.SimSites.init();
}
xm.OnPopupShowing = function() {
if (xm.gSettings.hideStatusIcon) {
document.getElementById("foxmarks-showstatusicon").
removeAttribute("checked");
} else {
document.getElementById("foxmarks-showstatusicon").
setAttribute("checked", "true");
}
return true;
};
xm.ToggleIcon = function(event) {
xm.gSettings.hideStatusIcon = !xm.gSettings.hideStatusIcon;
};
function FoxmarksBrowserUnload() {
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
try {
os.removeObserver(foxmarksObserver, "foxmarks-service");
} catch (e) {
Xmarks.LogWrite("Warning: removeObserver failed.");
}
}
window.addEventListener("load", FoxmarksBrowserLoad, false);
window.addEventListener("unload", FoxmarksBrowserUnload, false);
})();